package com.lzh.chatnote.chat.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 幂等类型
 */
@AllArgsConstructor
@Getter
public enum PushTypeEnum {
    //0 群推送 1全员推送
    GROUP(0, "群推送"),
    ALL(1, "全员推送");

    private final Integer type;
    private final String desc;

    private static Map<Integer, PushTypeEnum> cache;

    static {
        cache = Arrays.stream(PushTypeEnum.values()).collect(Collectors.toMap(PushTypeEnum::getType, Function.identity()));
    }

    public static PushTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
